<?php 

function dateValid($date=null)
{
	//buat array nama hari dalam bahasa Indonesia dengan urutan 1-7
	$array_hari = array(1=>'Senin','Selasa','Rabu','Kamis','Jumat', 'Sabtu','Minggu');
	//buat array nama bulan dalam bahasa Indonesia dengan urutan 1-12
	$array_bulan = array(1=>'Januari','Februari','Maret', 'April', 'Mei', 'Juni','Juli','Agustus',
					'September','Oktober', 'November','Desember');
	
	if ($date == '0000-00-00' || $date == '1970-01-01' || $date == null ){
		return "";
	} else {
		//jika $date diisi, makan tanggal yang diformat adalah tanggal tersebut
		$date  = strtotime($date);
		$hari  = $array_hari[date('N',$date)];
		$tanggal = date ('j', $date);
		$bulan = $array_bulan[date('n',$date)];
		$tahun = date('Y',$date);
		$formatTanggal = $tanggal ." ". $bulan ." ". $tahun;
		return $formatTanggal;
	}
}if(@$type!=="excel") { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Laporan Detail Jadwal</title>
<?php echo css_asset("printstyle.css"); ?>
</head>
<body>
<?php } else { ?>
<html xmlns:o="urn:schemas-microsoft-com:office:office"
                                       xmlns:x="urn:schemas-microsoft-com:office:excel"
                                        xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Laporan Detail Jadwal</title>
<style>
.table{
        border-collapse:collapse;      
}
</style>
<xml>
 <x:ExcelWorkbook>
  <x:ExcelWorksheets>
   <x:ExcelWorksheet>
    <x:Name>Sheet</x:Name>
    <x:WorksheetOptions>
     <x:Print>
        <x:Gridlines />
     </x:Print>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
  </x:ExcelWorksheets>
 </x:ExcelWorkbook>
</xml>
</head>
<body>
<?php } 
if (count($data_print) > 0 ) {
?>
<table summary='Laporan Detail Jadwal' width="100%" class="print">
	<caption>Laporan Detail Jadwal</caption>
	<thead>
		<tr>
			<th scope='col' rowspan=2>No</th>
			<th scope='col' rowspan=2>Nama Proyek</th>
			<th scope='col' rowspan=2>Kondisi</th>
			<th scope='col' rowspan=2>NK (Pagu)</th>
			<th scope='col' colspan=3>Contract Review</th>
			<th scope='col' rowspan=2>Aanwijz</th>
			<th scope='col' rowspan=2>Pemasukan</th>
			<th scope='col' rowspan=2>Proses Kontrak</th>
			<th scope='col' rowspan=2>Update Status</th>
			<th scope='col' rowspan=2>&nbsp;</th>
		</tr>
		<tr>
			<th scope='col'>CR</th>
			<th scope='col'>MR</th>
			<th scope='col'>Ijin < 50 M</th>
		</tr>
	</thead>
	<tbody>
		<?php $cabang = ""; $cabangcount = 0; $i=0; foreach($data_print as $print) { $i++; ?>
		<?php if($cabang != $print->cabang_nama ){
			$i = 1;
			$cabang = $print->cabang_nama;
			$cabangcount ++;
			echo "<tr style='font-size:larger;'><td><b>".latinToRomawi($cabangcount)."</b></td><td><b>".$cabang."</td></b><td colspan=10>&nbsp;</td></tr>";
		}?>
		<tr <?php if ($print->kondisi_nama != "PASCA")  echo 'style="border-bottom:2px solid #000;"'; ?>>
			<td><?php echo $i; ?></td>
			<td><?php echo $print->jadwal_namaproyek; ?></td>
			<td><?php echo $print->kondisi_nama; ?></td>
			<td style="text-align:right"><?php echo number_format($print->jadwal_nk,0,",","."); ?></td>
			<td><?php if($print->jadwal_flagcr == "Y")  echo dateValid($print->jadwal_tglpemasukan); else echo "-"; ?></td>
			<td><?php if($print->jadwal_flagmr == "Y") echo "&nbsp;"; else echo "-"; ?></td>
			<td><?php if($print->jadwal_flagijin == "Y") echo "&nbsp;"; else echo "-"; ?></td>
			<td><?php echo dateValid($print->jadwal_tglaan); ?></td>
			<td><?php $tgl_pemasukan = dateValid($print->jadwal_tglpemasukan);
                echo ($tgl_pemasukan != "")? $tgl_pemasukan." (File 1) ": "";  $tgl_pemasukan2 = dateValid($print->jadwal_tglpemasukan2);
                   echo "<br />";
                echo ($tgl_pemasukan2 != "")? $tgl_pemasukan2." (File 2) ": ""; ?></td>
			<td><?php echo dateValid($print->jadwal_tglkontrak); ?></td>
			<td><?php echo $print->jadwal_updatestatus; ?></td>
			<td>Koord : <?php echo $print->jadwal_koordinator; ?></td>
			</tr>
		<?php 
			if ($print->kondisi_nama == "PASCA"){
		?>
			<tr>
			<td>&nbsp;</td>
			<td>1. Pra Brainstorming</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>Angg : <?php echo $print->jadwal_anggaranpicname; ?></td>
			</tr>
			<tr>
			<td>&nbsp;</td>
			<td>2. Brainstorming I (Adm & prametode)</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>Metode : <?php echo $print->jadwal_metodepicname; ?></td>
			</tr>
			<tr>
			<td>&nbsp;</td>
			<td>3. Brainstorming II (metode)</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>ME : <?php echo $print->jadwal_mepicname; ?></td>
			</tr>
			<tr>
			<td>&nbsp;</td>
			<td>4. Finalisasi</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>Harga : <?php echo $print->jadwal_hargapicname; ?></td>
			</tr>
			<tr>
			<td>&nbsp;</td>
			<td>5. Cek dokumen ( final )</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>Vol : <?php echo $print->jadwal_volumepicname; ?></td>
			</tr>
			<tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			</tr>
			<tr style="border-bottom:2px solid #000;">
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>Expert : <?php echo $print->jadwal_expertpicname; ?></td>
			</tr>
			
		<?php
			}
		} ?>
	</tbody>
	<tfoot><tr><th scope='row'>Total</th><td colspan='11'><?php echo count($data_print); ?></td></tr></tfoot>
	</table>	<?php  }else{ ?>
		<center><b>Tidak ada data yang ditemukan!</b></center>
		<?php } ?>
</body>
</html>